package com.itce.arco.test;

public class test1 {
    public static void main(String[] args) {
        int[] nums = new int[]{-1,0,3,5,9,12};
        int search = search(nums, 8);
        System.out.println(search);
    }
    public static int search(int[] nums, int target) {
        int low = 0;
        int high = nums.length - 1;
        int mid;
        while(low <= high) {
            mid = (low + high)/2;
            if (nums[mid]==target) {
                return nums[mid];
            }
            if (nums[mid]<target) {
                low = mid + 1;
            } else {
                high = mid - 1;
            }
        }
        return -1;
    }
}
